from sqlite3.dbapi2 import Date

from wordcloud import WordCloud
import matplotlib.pyplot as plt
import time


def creat_word_cloud(filename):
    text = open("{}.txt".format(filename), encoding='utf-8').read()
    wc = WordCloud(
        background_color="white",
        max_words=2000,
        font_path='C:\Windows\Fonts\msyh.ttc',
        height=1080,
        width=1980,
        max_font_size=100,
        random_state=30
    )
    myword = wc.generate(text)
    plt.imshow(myword)
    plt.axis("off")
    name = time.strftime("%Y%m%d%H%M%S", time.localtime()).__str__()
    wc.to_file(name+'.png')

if __name__ == '__main__':
    creat_word_cloud('bzhan')
